<?php
	$user_phone = $user->phone; // empty doit avoir des l'accès direct à la variable
	$user_fb_session = $user->fb_session;
	$user_tw_token = $user->tw_token;

	$phone = empty($user_phone) ? "aucun" : $user->phone;
	$login = empty($user_fb_session) ? "erreur" : "OK";
	$twitter = empty($user_tw_token) ? "erreur" : "OK";
	
	$user->setFbAPI($cfg->getFacebook());
	$offline_access = $user->hasOfflineAccess() ? "OK" : "erreur";
	$publish_stream = $user->hasPublishStream() ? "OK" : "erreur";
	
	$now = time();
	
	if($now - $user->location_date > $cfg->geoloc_timeout) {
		$orange = new OrangeAPI($cfg->or_api_key);
		$georesp = $orange->geoloc($user->getValidPhone());
		$geoloc = $georesp->isValid() ? "OK" : "erreur ".$georesp->getStatusCode;
		
		$user->location_date = $now;
		$user->save();
	}
	elseif($user->longitude != 0 && $user->latitude != 0)
		$geoloc = "OK";
	else 
		$geoloc = "erreur";
		
	
	$Smarty->assign('phone', $phone);
	$Smarty->assign('login', $login);
	$Smarty->assign('twitter', $twitter);
	$Smarty->assign('geoloc', $geoloc);
	$Smarty->assign('offline_access', $offline_access);
	$Smarty->assign('publish_stream', $publish_stream);
	$Smarty->assign('page', 'home.tpl');
?>

